package com.example.manager;

import com.example.model.Block;

public class BlockManager {
    public static final BlockManager defaultManager = new BlockManager();
    //保存预览方块对象
    private Block previewBlock;
    //保存正在显示的方块
    private Block currentBlock;
    private BlockManager(){

    }

    public void resetPosition(int row, int column){
        currentBlock.row = 0;
        currentBlock.column = column / 2 - 1;

        previewBlock.row = 0;
        previewBlock.column = column / 2 - 1;
    }

    //获取预览方块
    public Block getPreviewBlock(int row,int column){
        if (currentBlock == null){
            //第一次获取方块，currentBlock要产生方块
            currentBlock = new Block(row,column);
        }
        else {
            //已经有方块了，当前看到的方块就是之前预览的方块
            currentBlock = previewBlock;
        }
        //创建一个新的block对象
        previewBlock = new Block(row,column);
        return previewBlock;
    }

    //获取当前正在操作的方块
    public Block getCurrentBlock(){
        return currentBlock;
    }
}
